package com.gang.mars.aop.test;

import com.gang.mars.aop.config.AppConfig;
import com.gang.mars.aop.service.HelloWorldService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 类说明：gang.chen springboot深度实践
 *
 * @author gang.chen
 * @since 2022/5/15
 */
public class SpringAopTestCase {

    public static void main(String[] args) {

        //proxyFactoryBeanTest1();
        proxyFactoryBeanTest2();
    }

    public static void proxyFactoryBeanTest2(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        HelloWorldService helloWorldService = (HelloWorldService) context.getBean("helloWorldServiceImpl");
        helloWorldService.test1();
    }

    public static void proxyFactoryBeanTest1(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        HelloWorldService proxyFactoryBean = (HelloWorldService) context.getBean("proxyFactoryBean");
        proxyFactoryBean.test1();
    }
}
